#include "process.h"

typedef void(*call_t)(const char*, double, double);

double speed[] = {20.0, 0.2, 0.05, 0.1, 0.01};

void Download(double total, call_t ca)
{
    srand(time(NULL));
    double current = 0.0;
    while(current <= total)
    {
        ca("下载中...", total, current);

        usleep(10000);
        
        int random = rand() % 5;
        current += speed[random];
    }
    if(current > total) current = total;
    ca("下载完成 ", total, current);
    printf("\n");
}

int main()
{
    Download(1024.0, FlushProcess);
    return 0;
}

//int main()
//{
//    process();
//    return 0;
//}
